﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Site.Master" AutoEventWireup="true" CodeBehind="AllApplication.aspx.cs" Inherits="CRMWeb.Pages.EasyUISamples.AllApplication" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

     <table id="dg" title="All Applications Information" class="easyui-datagrid" style="width: 1000px; height: 610px"
        url="/WebServices/ApplicationSelect.ashx"
        toolbar="#toolbar" pagination="true" data-options="pageSize:20"
        rownumbers="true" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="app_FirstName1" width="50">First Name 1</th>
                <th field="app_FirstName2" width="50">First Name 2</th>
                <th field="app_MiddleName1" width="50">Middle Name 1</th>
                <th field="app_MiddleName2" width="50">Middle Name 2</th>
                <th field="app_Surname1" width="50">Surname 1</th>
                <th field="app_Surname2" width="50">Surname 2</th>
                <th field="app_Date" width="50">Date</th>
                <th field="app_Time" width="50">Time</th>
            </tr>
        </thead>
    </table>
    <div id="toolbar">
              <span>FirstName:</span>  
        <input id="search_firstname" style="line-height:26px;border:1px solid #ccc">  
       
        <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>
    </div>
    
    <div id="dlg" class="easyui-dialog" style="width: 400px; height: 280px; padding: 10px 20px"
        closed="true" buttons="#dlg-buttons">
        <div class="ftitle">Book Information</div>
        <form id="fm" method="post">
            <div class="fitem">
                <label>First Name:</label>
                <input name="app_FirstName1" class="easyui-validatebox" required="true">
            </div>
            <div class="fitem">
                <label>Middle Name:</label>
                <input name="app_MiddleName1" class="easyui-validatebox" required="true">
            </div>
            <div class="fitem">
                <label>Surname:</label>
                <input name="app_Surname1">
            </div>
            <div class="fitem">
                <label>Date:</label>
                <input name="app_Date">
            </div>
        </form>
    </div>
   
    <div id="dlg-buttons">
        <a href="#" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveBook()">Save</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
    </div>

    <script type="text/javascript">
        var url;

        $('#dg').datagrid({
            onDblClickRow: function (index,rowdata) {
                alert(index + " "+ rowdata.app_FirstName1);               
            }
        })


        function newBook() {
            $('#dlg').dialog('open').dialog('setTitle', 'New Book');
            $('#fm').form('clear');
            url = 'Test1_Insert.ashx';
        }
        function editBook() {
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                $('#dlg').dialog('open').dialog('setTitle', 'Edit Book');
                $('#fm').form('load', row);
                url = 'Test1_Update.ashx?id=' + row.id;
            }
        }
        function saveBook() {
            $('#fm').form('submit', {
                url: url,
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (result) {
                    var result = eval('(' + result + ')');
                    if (result.errorMsg) {
                        $.messager.show({
                            title: 'Error',
                            msg: result.errorMsg
                        });
                    } else {
                        $('#dlg').dialog('close');		// close the dialog
                        $('#dg').datagrid('reload');	// reload the user data
                    }
                }
            });
        }
        function deleteBook() {
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                $.messager.confirm('Confirm', 'Are you sure you want to delete this book?', function (r) {
                    if (r) {
                        $.post('Test1_Delete.ashx', { id: row.id }, function (result) {
                            if (result.success) {
                                $('#dg').datagrid('reload');	// reload the user data
                            } else {
                                $.messager.show({	// show error message
                                    title: 'Error',
                                    msg: result.errorMsg
                                });
                            }
                        }, 'json');
                    }
                });
            }
        }

        function doSearch() {
            $('#dg').datagrid('load', {
                firstname: $('#search_firstname').val()            
            });
        }
        
    </script>
    <style type="text/css">
        #fm {
            margin: 0;
            padding: 10px 30px;
        }

        .ftitle {
            font-size: 14px;
            font-weight: bold;
            padding: 5px 0;
            margin-bottom: 10px;
            border-bottom: 1px solid #ccc;
        }

        .fitem {
            margin-bottom: 5px;
        }

            .fitem label {
                display: inline-block;
                width: 80px;
            }
    </style>

</asp:Content>
